import Vue from 'vue'
import VeeValidate, {
	Validator
} from 'vee-validate';
// import * as VeeValidate from 'vee-validate';
import * as rules from 'util/dictionary.js';
import zh_CN from 'vee-validate/dist/locale/zh_CN';
import VueI18n from "vue-i18n";
Vue.use(VueI18n);
const i18n = new VueI18n({
	locale: "zh_CN"
});
// vee-validate配置
const config = {
	aria: true,
	classNames: {},
	classes: false,
	delay: 0,
	dictionary: {
		zh_CN
	},
	errorBagName: "errors", // change if property conflicts
	events: "blur",
	fieldsBagName: "fields",
	i18n: i18n, // the vue-i18n plugin instance
	i18nRootKey: "validations", // the nested key under which the validation messages will be located
	inject: true,
	// 这一荐项目跟后面的dictionary.zh_CN对应
	locale: "zh_CN",
	validity: false
};
Vue.use(VeeValidate, config);


// 自定义validate
const dictionary = {
	zh_CN: {
		attributes: {
			username: '姓名',
			password: '密码',
			phone: '手机号',
			email:'邮箱',
			applyTitle:'申请标题',
			message:'申请内容',
			realName:'申请人'
		},
		messages: {
			required: (field) => '请提交' + field+'信息',
			email:(field) => '邮箱不合法，请重新输入',
			url:(field) => field+'不是有效的网址'
		},
	}
}
Validator.localize(dictionary);

/*自定义方法*/
Validator.extend("phone",rules.isMobile);
